program ProductOfPolynomials;

{$APPTYPE CONSOLE}

uses
  SysUtils;

type
  pelement= ^element;
  element = record
    value1: Integer;
    value2: Integer;
    next: pelement;
  end;

var
  n, n1, n2, num1, num2, i: Integer;
  head1, head2, head3, current1, current2: pelement;
  fin: TextFile;

procedure AddToBegin (var head: pelement; num1, num2: Integer);
var tmp: pelement;
begin
  tmp:=head;
  New (head);
  head^.value1:=num1;
  head^.value2:=num2;
  head^.next:=tmp;
end;

procedure AddToEnd (var head: pelement; num1, num2: Integer);
begin
  if (head<>nil) then
  begin
    AddToBegin (head, num1, num2);
  end else begin
    AddToEnd(head^.next, num1, num2);
  end;
end;

procedure PrintList (head: pelement);
var current: pelement;
begin
  current:=head;
  while (current<>nil) do
  begin
    Writeln (current^.value1, ' ', current^.value2);
    current:=current^.next;
  end;
end;



begin
  AssignFile (fin, 'inputt.txt');
  Reset (fin);
  readln (fin, n1);
  for i:=0 to n1-1 do
  begin
    readln (fin, num1, num2);
    AddToEnd (head1, num1, num2);
  end;
  readln (fin, n2);
  for i:=0 to n2-1 do
  begin
    readln (fin, num1, num2);
    AddToEnd (head2, num1, num2);
  end;
  if n1>n2 then
  begin
    n:=n1;
  end else begin
    n:=n2;
  end;
  current1:=head1;
  current2:=head2;
  for i:=0 to n-1 do
  begin
    while (current1^.next<>nil) and (current2^.next<>nil)  do
    begin
      AddToEnd (head3, current1^.value1+current2^.value1, current1^.value2+current2^.value2);
      current1:=current1^.next;
      current2:=current2^.next;
    end;
  end;
  PrintList (head3);
  Readln;
  Readln;
  Readln;
  CloseFile (fin);
end.
 